/**
 * Created by liangpure on 2017/5/7.
 */

import { fromJS, Map } from 'immutable'

export const UPDATE_TIME = 'UPDATE_TIME'
const date = new Date()
const initState = fromJS({
  time: {
    timestamp: date.getTime(),
    tag: date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
  }
})

function initAppData(state = initState, action) {
  switch (action.type) {
    case UPDATE_TIME: const date = new Date(); return state.mergeIn('time', Map({
      timestamp: date.getTime(),
      tag: date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate()
    }))
    default: return state
  }
}

export default initAppData
